aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/account/[id]
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-23 16:22:10 -0700
committerAdam Soltys <[email protected]>2024-09-23 16:22:10 -0700
commit52871e09d9218f3f2fb2ce4bd6e97f5c1fc15480 (patch)
tree543a0af922d193940846e7a953ed7b027a931e30 /src/routes/(app)/account/[id]
parent200c5ff1f4e41ed907a1dd4a0337d8ee0a94b8be (diff)
downloadcoinos-ui-52871e09d9218f3f2fb2ce4bd6e97f5c1fc15480.tar.gz
coinos-ui-52871e09d9218f3f2fb2ce4bd6e97f5c1fc15480.zip
account import
Diffstat (limited to 'src/routes/(app)/account/[id]')
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index df121168..3dcd99b8 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -1,13 +1,27 @@
<script>
+ import WalletPass from "$comp/WalletPass.svelte";
import { goto } from "$app/navigation";
- import { fail, focus, post } from "$lib/utils";
+ import { copy, fail, focus, post } from "$lib/utils";
import { enhance } from "$app/forms";
import { t } from "$lib/translations";
import Icon from "$comp/Icon.svelte";
+ import { decrypt } from "nostr-tools/nip49";
+ import { entropyToMnemonic, mnemonicToSeed } from "@scure/bip39";
+ import { wordlist } from "@scure/bip39/wordlists/english";
export let data;
let { account, user } = data;
- let { id, name } = account;
+ let { id, name, seed } = account;
+ let mnemonic, password;
+ let passwordPrompt;
+ let cancel = () => (passwordPrompt = false);
+ let toggle = () => (passwordPrompt = !passwordPrompt);
+
+ let submit = async () => {
+ toggle();
+ let entropy = await decrypt(seed, password);
+ mnemonic = entropyToMnemonic(entropy, wordlist);
+ };
let del = async () => {
try {
@@ -35,15 +49,45 @@
class="rounded-2xl border py-3 font-bold mx-auto bg-black text-white px-4 w-full"
>Submit</button
>
+ {#if mnemonic}
+ <div class="p-8">{mnemonic}</div>
+
+ <button
+ on:click={() => copy(mnemonic)}
+ type="button"
+ class="flex gap-2 rounded-2xl border py-3 font-bold mx-auto px-4 w-full justify-center"
+ >
+ <Icon icon="copy" style="w-8 my-auto" />
+ <div class="my-auto">Copy</div></button
+ >
+ {:else if seed}
+ <button
+ on:click={toggle}
+ type="button"
+ class="flex gap-2 rounded-2xl border py-3 font-bold mx-auto px-4 w-full justify-center bg-primary"
+ >
+ <Icon icon="eye" style="w-8 my-auto" />
+ <div class="my-auto">Reveal mnemonic</div></button
+ >
+ {/if}
+
+ {#if seed}
<button
on:click={del}
type="button"
- class="flex gap-2 rounded-2xl border py-3 font-bold mx-auto px-4 w-full justify-center border-red-600 border-2"
+ class="flex gap-2 rounded-2xl border py-3 font-bold mx-auto px-4 w-full justify-center bg-primary"
>
<Icon icon="trash" style="w-8 my-auto" />
- <div class="my-auto">Delete</div></button
+ <div class="my-auto"><span class="text-red-600">Delete</span> account</div></button
>
+ {/if}
</div>
+
+ <div />
</form>
</div>
</div>
+
+{#if passwordPrompt}
+ <WalletPass bind:password bind:cancel bind:submit />
+{/if}